package com.fqgj.xjd.user.dao.impl;

import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.xjd.user.dao.UserAuthHighmarkDao;
import com.fqgj.xjd.user.entity.UserAuthHighmarkEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: Karl
 * Date: 2019-10-12
 * Time: 14:13:49.498
 */

@Repository
public class UserAuthHighmarkDaoImpl extends AbstractBaseMapper<UserAuthHighmarkEntity> implements UserAuthHighmarkDao {

    @Override
    public List<UserAuthHighmarkEntity> selectUserAuthHighmarkByParams(Map<String, Object> params) {
        if (!params.containsKey("deleted")) {
            params.put("deleted", 0);
        }
        return getSqlSession().selectList(getStatement("selectByParams"), params);
    }

    @Override
    public UserAuthHighmarkEntity selectLastUserAuthHighmark(String userCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        return getSqlSession().selectOne(getStatement("selectLastUserAuthHighmark"), params);
    }

    @Override
    public UserAuthHighmarkEntity selectLastUserAuthHighmarkByPanCardNo(String panCardNo, boolean isOriginal) {
        Map<String, Object> params = new HashMap<>();
        params.put("panCardNo", panCardNo);
        params.put("dataFrom", isOriginal ? "third" : null);
        return getSqlSession().selectOne(getStatement("selectLastUserAuthHighmarkByPanCardNo"), params);
    }

    @Override
    public UserAuthHighmarkEntity selectUserAuthHighmarkByOrderId(String userCode, String orderId) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        params.put("orderId", orderId);
        return getSqlSession().selectOne(getStatement("selectUserAuthHighmarkByOrderId"), params);
    }

    @Override
    public List<UserAuthHighmarkEntity> selectLast3Record(String userCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        return getSqlSession().selectList(getStatement("selectLast3Record"), params);
    }

    @Override
    public List<UserAuthHighmarkEntity> selectUnAnalyseHighmarkList(Page page) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        return getSqlSession().selectList(getStatement("selectUnAnalyseHighmarkList"), params);
    }
}

